package com.gxsyh.nantie.statements.management.provider.util;

import com.gxsyh.nantie.statements.management.provider.domain.*;
import com.gxsyh.nantie.statements.management.provider.service.TbDepartmentService;
import com.gxsyh.nantie.statements.management.provider.service.UserOrderCountService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

public class RailwayOrderContUtil {

    @Resource
    private TbDepartmentService tbDepartmentService;

    @Resource
    private UserOrderCountService userOrderCountService;

    /**
     * 计算班组下用户的消费情况
     * @param userOrderInfos
     */
    public UserOrderCount countUserOrder(List<UserOrderInfo> userOrderInfos)
    {
        Double subsidy=new Double(0);
        Double amountConsumption=new Double(0);
        Integer cashCount=new Integer(0);
        Integer subsidyCount=new Integer(0);
        Double cashConsumption=new Double(0);
        Double subsidyConsumption=new Double(0);
        for (UserOrderInfo list: userOrderInfos)
        {
            amountConsumption+=list.getAmountConsumption();
            if (list.getSubsidy()==0)
            {
                cashCount++;
                cashConsumption+=list.getAmountConsumption();
            }else{
                subsidyCount++;
                subsidy+=list.getSubsidy();
                subsidyConsumption+=list.getAmountConsumption();
            }
        }
        UserOrderCount userOrderCount=new UserOrderCount();
        userOrderCount.setAmountConsumption(amountConsumption);
        userOrderCount.setSubsidy(subsidy);
        userOrderCount.setOrderCount(userOrderInfos.size());
        userOrderCount.setCashCount(cashCount);
        userOrderCount.setSubsidyCount(subsidyCount);
        userOrderCount.setCashConsumption(cashConsumption);
        userOrderCount.setSubsidyConsumption(subsidyConsumption);

        return userOrderCount;
    }

}
